
package com.sskj.jkzx.repository.amap.message;

import java.util.List;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import com.sskj.jkzx.domain.entity.amap.message.Message;
import com.sskj.jkzx.repository.GenericPagerRepository;

@Repository
public interface MessageRepository extends GenericPagerRepository<Message, String> {

	@Query(value = "select * from jkzx_message t order by t.created_time desc limit 1", nativeQuery = true)
	Message findLastOne();

	@Query(value = "select * from jkzx_message t order by t.created_time desc", nativeQuery = true)
	List<Message> findAllOrderByCreatedTime();

	// 查询记录数量
	@Query(value = "select count(*) from jkzx_message t where t.type=:type and to_days(now())-to_days(t.created_time)=:day ", nativeQuery = true)
	long findTodayCountByType(@Param("type") String type, @Param("day") Integer day);

}
